import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main3 {
    public static int count = 0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        boolean flag = isMos(s);
        if(count == s.length()) {
            System.out.println(0);
            return;
        }

        if(flag) {
            System.out.println(s.length() - 1);
        } else {
            System.out.println(s.length());
        }
    }

    public static boolean isMos(String s) {
        int left = 0;
        int right = s.length() - 1;
        char ch = s.charAt(0);
        boolean flag = true;
        while(left < right) {
            char cL = s.charAt(left);
            char cR = s.charAt(right);
            if(cL == ch) count++;
            if(cR == ch) count++;
            if(cL != cR) {
                flag = false;
                break;
            }
            left++;
            right--;
        }
        if(left == right) {
            char cM = s.charAt(left);
            if(ch == cM) count++;
        }
        return flag;
    }
}